<?php


// Insert here the the title of your feed
$rss_title= "WOWWVOTE  RSS feed";  
// Insert your site, in the format site.com
$rss_site= "apps.podzone.net/ushahidi/" ;
// Insert the description of your website
$rss_description= "Description of your RSS feed";
// Applicable language of the feed. For spanish, change to "es"
$rss_language="en";                     
// Address of the logo file. It can be called whatever you want it to be!
$rss_logo="http://www.".$rss_site."/images/rss.gif";  
// the feed's author email
$emailadmin="your@emailaddress.com";   

// set the file's content type and character set
// this must be called before any output
header("Content-Type: text/xml;charset=iso-8859-1");


// Open the database

#Connect to database
$dbhost = 'localhost';
$dbuser = 'gammu-n5000';
$dbpasswd = 'g@mmu-n500O';
$dbname = 'gammu_n5000';

mysql_connect($dbhost, $dbuser, $dbpasswd) or die ( mysql_error() );
mysql_select_db($dbname) or die(mysql_error());

// Select all the records from the Articles/Blog table - whatever you're using it for


$query = "select * from Inbox ORDER BY timestamp desc   " ;
$result = mysql_query($query) or die(mysql_error() ) ;

echo
'<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<title>'.$rss_title.'</title>
      <link>http://apps.podzone.net/ushahidi/feeds/</link>
      <description>'.$rss_description.'</description>
      <language>en-en</language>
    <image>
<url>'.$rss_logo.'</url>
<title>'.$rss_site.'</title>
<link>http://www.'.$rss_site.'</link>
</image>';


for($i=0;$i<15; $i++) //will loop through 6 times to generate 6 RSS items
{
	$photo_name = 'where-ever a photo for this article could be found - needs to be http://www.yoursite.com/images/whatever.gif';     

	$sender = substr( mysql_result($result,$i,'sending_number') ,1, 11); //subject line for the RSS item
	
	$query2 = "select * from allowed_users where number = ' ".$sender."' limit 1";
	$result2 = mysql_query($query2) or die ( mysql_error() );
	$allowed = mysql_fetch_assoc( $result2 );
	
	$allowed_num = $allowed["number"]; //make sure the number that gets added to the feed is an allowed number
	$allowed_user = $allowed["username"];
	/*	
	if( strcmp( $sender,$allowed_num) == 0 )
		{$sender = $allowed_num;}	
	else
		{continue;}
	*/
	// Pass the record URL_product to the variable $url_product. It also
	// has to include the relative path, like in: "path/product1.htm"

	$url_product = '/articles/wherever_your_article/blog_can_be_found'; //define the URL of where people could read this blog/article entry
	
	// Define a description of the item
	
	$description = mysql_result($result,$i,'message'); //easiest way is by grabbing the content
	
	// Clean the description
	
	$description = str_replace ("&amp","",$description);
	
	// Pass tags to describe the product - this has been left ouf of this example
	
	$rss_tags = 'tag1, tag2';
	
	//This is a teaser of your article, basically what RSS readers will show the user in their inbox.  
	//This is how you entice users to come over and read the full article
	
	//the easiest way is to just take the first few hundred characters of the content (description)
	
	//$short_description = substr($description,0,160) ;
	
	//so you can define when it was published
	
	$timestamp = mysql_result($result,$i,'timestamp');
	
	//cleans the timestamp into an RSS friendly format
	
	$pubdate = date("r", strtotime("now"));
	
	//outputs the RSS item
	
	echo
	"
		<item>
			<title> $timestamp: $description</title>
				<link>http://apps.podzone.net/ushahidi/feeds</link>
				<guid isPermaLink=\"true\">http://apps.podzone.net/ushahidi/feeds/$i</guid>
					<description> </description>
					<pubDate>$pubdate</pubDate>
		</item>
	
	
	";
	
	$sender = $allowed_num = $allowed_user = "";
	mysql_free_result($result2);	
} //end of the for-loop

mysql_close(); //close the DB

echo //close the XML file
' </channel>
</rss>';


?>
